package com.zlz.open.dict.controller;

import com.zlz.base.entity.response.PageInfo;
import com.zlz.base.entity.response.ResultSet;
import com.zlz.open.dict.bean.request.DictGroupRequest;
import com.zlz.open.dict.bean.request.DictValueRequest;
import com.zlz.open.dict.bean.vo.DictGroupResponse;
import com.zlz.open.dict.bean.vo.DictValueResponse;
import com.zlz.open.dict.service.DictGroupService;
import com.zlz.open.dict.service.DictValueService;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.util.List;

@RestController
@RequestMapping("/dict")
public class DictValueController {

    private final DictValueService dictValueService;

    public DictValueController(DictValueService dictValueService) {
        this.dictValueService = dictValueService;
    }

    @PostMapping(value = "/value/create")
    public Mono<ResultSet<Long>> create(@RequestBody Mono<DictValueRequest> request) {
        return dictValueService.createDictValue(request);
    }

    @PostMapping(value = "/value/save")
    public Mono<ResultSet<Long>> save(@RequestBody Mono<DictValueRequest> request) {
        return dictValueService.save(request);
    }

    @PostMapping("/value/selectList")
    public Mono<ResultSet<List<DictValueResponse>>> selectList(@RequestBody Mono<DictValueRequest> request) {
        return dictValueService.selectList(request);
    }

    @PostMapping("/value/update")
    public Mono<ResultSet<Long>> updateGroup(@RequestBody Mono<DictValueRequest> request) {
        return dictValueService.updateDictValue(request);
    }

    @PostMapping("/value/delete")
    public Mono<ResultSet<String>> deleteGroup(@RequestBody Mono<DictValueRequest> request) {
        return dictValueService.deletedValue(request);

    }

}
